﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using GroupManager.Class;
using GroupManager.Resource.CSDL;

namespace GroupManager
{
    public partial class ThongTinKhenThuong : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            string mdoinhom = Request.QueryString["doinhom"];
            int madoinhom = int.Parse(mdoinhom);
            DataList1.DataSource = LopKhenThuong.LayDanhSachKhenThuongHienThiTrangChuTheoMaDoiNhom(madoinhom);
            DataList1.DataBind();
        }

        protected void DataList1_ItemCommand(object source, DataListCommandEventArgs e)
        {
            if (e.CommandName == "Button1")
            {
                int makhen = Convert.ToInt32(e.CommandArgument);
                Button butten, butdvcap, butcap, butnamcap;
                butten = (Button)DataList1.Items[e.Item.ItemIndex].FindControl("Label1");
                butdvcap = (Button)DataList1.Items[e.Item.ItemIndex].FindControl("Label2");
                butcap = (Button)DataList1.Items[e.Item.ItemIndex].FindControl("Label3");
                butnamcap = (Button)DataList1.Items[e.Item.ItemIndex].FindControl("Label4");
                LopKhenThuong.SuaKhenThuong(makhen,butten.Text,butdvcap.Text,butcap.Text,Convert.ToInt32(butnamcap.Text));
                DataList1.DataBind();
                UpdatePanel1.Update();
            }

            if (e.CommandName == "button2")
            {
                int makhen = Convert.ToInt32(e.CommandArgument);
                LopKhenThuong.XoaKhenThuong(makhen);
                DataList1.DataBind();
                UpdatePanel1.Update();
            }
        }


    }
}